package com.zlict.admin.service.impl;

import java.util.List;

import cn.hutool.core.util.ObjectUtil;
import com.zlict.common.utils.DateUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zlict.admin.mapper.RdPortfolioAssetsMapper;
import com.zlict.admin.domain.RdPortfolioAssets;
import com.zlict.admin.service.IRdPortfolioAssetsService;

/**
 * 资产管理-组合资产Service业务层处理
 * 
 * @author lqh
 * @date 2025-06-17
 */
@Service
@RequiredArgsConstructor
public class RdPortfolioAssetsServiceImpl implements IRdPortfolioAssetsService 
{
    private final RdPortfolioAssetsMapper rdPortfolioAssetsMapper;

    /**
     * 查询资产管理-组合资产
     * 
     * @param id 资产管理-组合资产主键
     * @return 资产管理-组合资产
     */
    @Override
    public RdPortfolioAssets selectRdPortfolioAssetsById(Long id)
    {
        return rdPortfolioAssetsMapper.selectRdPortfolioAssetsById(id);
    }

    /**
     * 查询资产管理-组合资产列表
     * 
     * @param rdPortfolioAssets 资产管理-组合资产
     * @return 资产管理-组合资产
     */
    @Override
    public List<RdPortfolioAssets> selectRdPortfolioAssetsList(RdPortfolioAssets rdPortfolioAssets)
    {
        return rdPortfolioAssetsMapper.selectRdPortfolioAssetsList(rdPortfolioAssets);
    }

    /**
     * 新增资产管理-组合资产
     * 
     * @param rdPortfolioAssets 资产管理-组合资产
     * @return 结果
     */
    @Override
    public int insertRdPortfolioAssets(RdPortfolioAssets rdPortfolioAssets)
    {
        rdPortfolioAssets.setCreateTime(DateUtils.getNowDate());
        return rdPortfolioAssetsMapper.insertRdPortfolioAssets(rdPortfolioAssets);
    }

    /**
     * 修改资产管理-组合资产
     * 
     * @param rdPortfolioAssets 资产管理-组合资产
     * @return 结果
     */
    @Override
    public int updateRdPortfolioAssets(RdPortfolioAssets rdPortfolioAssets)
    {
        rdPortfolioAssets.setUpdateTime(DateUtils.getNowDate());
        return rdPortfolioAssetsMapper.updateRdPortfolioAssets(rdPortfolioAssets);
    }

    /**
     * 批量删除资产管理-组合资产
     * 
     * @param ids 需要删除的资产管理-组合资产主键
     * @return 结果
     */
    @Override
    public int deleteRdPortfolioAssetsByIds(Long[] ids)
    {
        return rdPortfolioAssetsMapper.batchUpdate(ids);
    }

    /**
     * 根据资产ID查询组合资产信息
     * @param rdPortfolioAssets
     * @return
     */
    @Override
    public RdPortfolioAssets getPortfolioAssetsById(RdPortfolioAssets rdPortfolioAssets) {
        if (ObjectUtil.isNotEmpty(rdPortfolioAssets)){
            if (ObjectUtil.isEmpty(rdPortfolioAssets.getId())){
                throw new RuntimeException("资产ID不能为空");
            }
        }
        //查询组合资产信息
        return rdPortfolioAssetsMapper.getPortfolioAssetsById(rdPortfolioAssets);
    }

    /**
     * 据组合资产查询添加过的仪器设备/建筑物列表
     *
     * @param rdPortfolioAssets
     * @return
     */
    @Override
    public List<RdPortfolioAssets> getPortfolioDetailListById(RdPortfolioAssets rdPortfolioAssets) {
        return rdPortfolioAssetsMapper.getPortfolioDetailListById(rdPortfolioAssets);
    }

    /**
     * 根据组合资产查询未添加过的仪器设备/建筑物列表
     *
     * @param rdPortfolioAssets
     * @return
     */
    @Override
    public List<RdPortfolioAssets> getFixedAssetsListById(RdPortfolioAssets rdPortfolioAssets) {
        return rdPortfolioAssetsMapper.getFixedAssetsListById(rdPortfolioAssets);
    }

    @Override
    public int batchEnable(Long[] ids) {
        if (ObjectUtil.isEmpty(ids)) {
            throw new RuntimeException("参数错误");
        }
        return rdPortfolioAssetsMapper.batchEnable(ids);
    }

    @Override
    public int batchDisable(Long[] ids) {
        if (ObjectUtil.isEmpty(ids)) {
            throw new RuntimeException("参数错误");
        }
        return rdPortfolioAssetsMapper.batchDisable(ids);
    }


}
